﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PrismTutorial.DataLayer {
    public abstract class BaseRepository {
        
        internal ADVConnection _context;
        internal bool _contextReused;

        public ADVConnection GetObjectContext() {
            if (!_contextReused) {
                return new ADVConnection();
            }
            return _context;
        }

        public void ReleaseObjectContextIfNotReused() {
            if (!_contextReused) {
                ReleaseObjectContext();
            }
        }

        public void ReleaseObjectContext() {
            if (_context != null) {
                _context.Dispose();
            }
            _contextReused = false;
        }
    }
}
